use clap::Parser;

// 导入模块中的内容
use rcli::{process_csv, process_genpass, Opts, SubCommand};

// rcli csv -i input.csv -o output.json
fn main() -> anyhow::Result<()> {
    let opts: Opts = Opts::parse();
    match opts.cmd {
        SubCommand::Csv(opts) => {
            let output = if let Some(output) = opts.output {
                output.clone()
            } else {
                // 如果没有指定output名称, 则使用默认名称
                format!("output.{}", opts.format)
            };
            process_csv(&opts.input, output, opts.format)?;
        }
        SubCommand::Genpass(opts) => {
            process_genpass(opts.length, opts.uppercase, opts.lowercase, opts.numbers, opts.symbols)?;
        }
    }

    Ok(())
}
